package com.zmn.oms.model.dto.work.masterwork;

import com.zmn.oms.common.vo.KVDict;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/**
 * @author sunlife
 * @date:2020/10/21 10:46 上午
 * description:
 */
@Data
public class WorkSharingEstimateDTO {
    /**
     * 分润主体类型 服务商/工程师
     */
    private String typeName;

    /**
     * 基础部分金额
     */
    private BasicSharingDRO basicSharing;

    /**
     * 绩效部分金额
     */
    private PerfSharingDRO perfSharing;

    /**
     * 补贴部分金额
     */
    private SubsidySharingDRO subsidySharing;

    /**
     * app端显示用list
     */
    private String subListJsonStr;

    @Data
    public static class BasicSharingDRO{
        /**
         * 基础预估分润
         */
        private Integer internalSettlementPrice;

        public Integer getTotalAmount() {
            return this.internalSettlementPrice;
        }
    }

    @Data
    public static class PerfSharingDRO {

        /**
         * 及时预约
         */
        private Integer onTimeDuty;

        /**
         * 准时上门
         */
        private Integer onTimeVisit;

        /**
         * 二十四小时完成
         */
        private Integer completeInDay;

        /**
         * 好评
         */
        private Integer praise;

        public Integer getTotalAmount(){
            return Optional.ofNullable(onTimeDuty).orElse(0) + Optional.ofNullable(onTimeVisit).orElse(0) + Optional.ofNullable(completeInDay).orElse(0) + Optional.ofNullable(praise).orElse(0);
        }

    }


    @Data
    public static class SubsidySharingDRO {

        /**
         * 远程补贴
         */
        private Integer distanceSubsidy;

        /**
         * 加急补贴
         */
        private Integer urgentSubsidy;

        /**
         * 区域补贴
         */
        private BigDecimal areaSubsidy;

        /**
         * 区域补贴金额
         */
        private Integer areaSubsidyAmount;

        public Integer getTotalAmount() {
            return Optional.ofNullable(distanceSubsidy).orElse(0) + Optional.ofNullable(urgentSubsidy).orElse(0) + Optional.ofNullable(areaSubsidyAmount).orElse(0);
        }

    }

}
